home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3016 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: 21 Jan 1996 09:34:07 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4dttefINNo29@keats.ugrad.cs.ubc.ca>
  8. References: <30C40F77.53B5@swsbbs.com> <4bd <4cc2b2$11jq@navajo.gate.net> <4cud8f$gup@news.netvision.net.il>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4cud8f$gup@news.netvision.net.il>,
  12. Uri Simchoni <simchoni@netvision.net.il> wrote:
  13. >In article <4cc2b2$11jq@navajo.gate.net>, feathers@gate.net says...
  14. >>Where I work, all the truly portable code is written in terms of 
  15. >>typedefs.  We alter the typedefs in an include file to alter data
  16. >>sizes and performance characeristic, and our variant of Hungarian
  17. >>uses these type names.
  18. >
  19. >I'm trying to get used to the idea...
  20. >
  21. >What if you have a variable which contains the delay between two 
  22. >operations in milliseconds. Do you make up a new type, say
  23. >
  24. >typedef unsigned MSEC
  25. >
  26. >and declare:
  27. >
  28. >MSEC cmsecDelayBetweenCharacters; ?
  29. >
  30. >Where do you put all those typedefs? in the beginning of the .c file, 
  31. >right before the declaration of in a separate .h file?
  32. >
  33. >Thanks for your response,
  34. >Uri
  35.  
  36. I say, don't bother. I avoid typedefs like the plague, even for structures. I
  37. much rather write the longer form.
  38.  
  39.     void myfunction(struct whatever *x);
  40.  
  41. Using excessive typedefs will just occlude your code. What is the point of
  42. having a separate type for MSEC? Later, when someone sees a declaration of a
  43. variable of type MSEC, he will have to go hunting and pecking for the
  44. definition of MSEC. It _obviously_ stands for milliseconds, but what the hell
  45. is it? 
  46.  
  47. I once help a guy debug his program which was for an operating systems course.
  48. He did things like typedef char * MESSAGE.  Now, his code looked as readable as
  49. a large print book from the community library, sure. But debugging it was
  50. awkward. I had no idea what the heck a MESSAGE was, at first glance. A
  51. structure? A string? An integer "cookie"? In fact, the bugs in the program were
  52. related to the severe levels of abstraction used in the naming of types and
  53. variables.
  54.  
  55. The prof himself called it "anal retentive" and encouraged the man to ease up a
  56. little bit. :)
  57.  
  58. All this talk about Hungarian Notation and whatnot is just silliness. To me,
  59. all identifiers declared in this notation look the same, and can be easily
  60. confused. When choosing a notation, plan ahead for the time when you are up at
  61. three in the morning with blood-shot eyes trying to find some bug! Think how
  62. these silly prefixes and suffixes will start to float in front of your eyes,
  63. and mingle like cream and coffee...
  64. -- 
  65.  
  66.